package com.ruoyi.project.system.domain;

import com.ruoyi.framework.aspectj.lang.annotation.Excel;
import com.ruoyi.framework.web.domain.BaseEntity;
import com.ruoyi.project.system.domain.vo.PriceItem;
import lombok.Data;
import java.math.BigDecimal;

/**
 * 查询对象 dt_final_result
 */
@Data
public class DtFinalResult extends BaseEntity {

    private static final long serialVersionUID = 1L;

    private Integer id;

    /**
     * 用户ID
     */
    @Excel(name = "用户ID")
    private Long userId;

    /**
     * 进件单号
     */
    @Excel(name = "进件单号")
    private Integer queryId;

    /**
     * 查询项目
     */
    @Excel(name = "查询项目")
    private Integer productId;

    /**
     * 查询内容
     */
    @Excel(name = "查询内容")
    private String info;

    /**
     * 扣前余额
     */
    @Excel(name = "扣前余额")
    private BigDecimal beforeBalance;

    /**
     * 扣费额
     */
    @Excel(name = "扣费额")
    private BigDecimal costNum;

    /**
     * 扣后余额
     */
    @Excel(name = "扣后余额")
    private BigDecimal afterBalance;

    public DtFinalResult() {
    }

    public DtFinalResult(Integer id) {
        this.id = id;
    }

    public DtFinalResult(DtQuery dtQuery, PriceItem priceItem, BigDecimal beforeBalance) {
        this.userId = dtQuery.getUserId();
        this.queryId = dtQuery.getQueryId();

        this.productId = priceItem.getId();
        this.costNum = priceItem.getPrice();

        this.beforeBalance = beforeBalance;
        this.afterBalance = beforeBalance.subtract(priceItem.getPrice());
    }

    public DtFinalResult(Long userId, Integer queryId, Integer productId, BigDecimal beforeBalance, BigDecimal costNum) {
        this.userId = userId;
        this.queryId = queryId;
        this.productId = productId;
        this.beforeBalance = beforeBalance;
        this.costNum = costNum;
        this.afterBalance = beforeBalance.subtract(costNum);
    }
}
